package com.zt.springcloud.factory;

import com.zt.springcloud.RemoteOrderService;
import com.zt.springcloud.entity.Vo.OrderListVo;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/9/15 8:57
 */

@Component
public class RemoteOrderFallbackFactory implements FallbackFactory<RemoteOrderService> {
    private static final Logger logger = LoggerFactory.getLogger(RemoteOrderFallbackFactory.class);
    @Override
    public RemoteOrderService create(Throwable throwable) {
        logger.info("订单服务调用失败:{}",throwable.getMessage());
        return new RemoteOrderService(){
            @Override
            public Boolean createOrder(String reqData,Long userId) {
                return false;
            }

            @Override
            public List<OrderListVo> getUserAllOrder(Long userId) {
                return null;
            }

            @Override
            public Boolean deleteOrderItem(String orderId) {
                return false;
            }
        };
    }
}
